import Vue from "vue";
import VueRouter from "vue-router";
import index from "../pages/Index";

// 要告诉 vue 使用 vueRouter
Vue.use(VueRouter);

const routes = [
    {
        path: "/",
        component: index,
        name: "index",
        meta: {
            title: '首页'
        }
    },
]

var router = new VueRouter({
    routes
})

router.beforeEach((to, from, next) => {
    /* 路由发生变化修改页面title */
    if (to.meta.title) {
        document.title = to.meta.title;
    }
    next();
})
export default router;